package net.xxcxcxcx.xc_enhancedmob.mixin.client;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;
import net.xxcxcxcx.xc_enhancedmob.render.boss_bar.BossBarsRendererHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Environment(value = EnvType.CLIENT)
@Mixin(InGameHud.class)
public class InGameHudMixin extends DrawableHelper {

    private static BossBarsRendererHelper bossBarsRenderer;

    @Inject(method = "render", at = @At("TAIL"))
    private void RenderBossBar(MatrixStack matrices, float tickDelta, CallbackInfo ci) {
        bossBarsRenderer.render(matrices, tickDelta);
    }

    @Inject(at = @At("TAIL"), method = "<init>")
    private void InGameHudAddBossBarsRenderer(MinecraftClient client, CallbackInfo ci) {
        bossBarsRenderer = new BossBarsRendererHelper(client);
    }
}
